Hệ thống bổ nhiệm bác sĩ trong PHP bằng mã nguồn

1 <?php if(!isset($_SESSION)){
2     session_start();
3     }
4 ?>
5
6 <?php include(
'header.php'); ?>
7
8
9
10
11     <!--
this is for donor registraton -->
12     <div
class="recipient_reg" style="background-color:#272327;">
13         <h3
class="text-center" style="background-color:#272327;color: #fff;">Add Doctor</h3>
14
15         <div
class="formstyle" style="float: right;padding:25px;border: 1px solid lightgrey;margin-right:320px; margin-bottom:30px;background-color: #101011;color:#d4530d;;">
16         <form enctype=
"multipart/form-data" action="" method="post" class="text-center" style="margin-left: 110px">
17              <div
class="col-md-12">
18                     
19                     
20                     <label>
21                         <input type=
"text" name="name" value="" placeholder="Full name" autocomplete="on">
22                     </label><br><br>
23                     <label>
24                          <input type=
"text" name="address" value="" placeholder="address" >
25                     </label><br><br>
26                     <label>
27                          <input type=
"text" name="contact" value="" placeholder="contact" >
28                     </label><br><br>
29
30                     <label>
31                          <input type=
"email" name="email" value="" placeholder="email" >
32                     </label><br><br>
33                     
34                     <label>
35                          <
select name="expertise" >
36                                         <option>-Expert
in-</option>
37                                         <option>Medicine</option>
38                                         <option>Heart</option>
39                                         <option>Bone</option>
40                                         <option>kedney</option>
41                                         </
select>
42                     </label><br><br>
43                     <label>
44                          <input type=
"text" name="userid" value="" placeholder="userid" >
45                     </label><br><br>
46                     <label>
47                        <input type=
"text" name="fee" value="" placeholder="Fee" >
48                     </label><br><br>
49                     <label>
50                        <input type=
"password" name="password" value="" placeholder="password" >
51                     </label><br><br>
52                     <label>
53                          <input type=
"file" name="pic" value="" id="pic" required>
54                     </label><br><br>
55                     
56                     <button name=
"submit" type="submit" style="margin-left:148px;margin-top: 4px;width:95px;border-radius: 3px;height: 30px">Add Doctor</button> <br>
57                 
58             </div> <!-- col-md-
12 -->
59
60
61                 </form>
62             </div>
63
64
65
66
67     </div>
68     
69     
70
71                     <!-- inserting data -->
72                     <?php
73                          
if(isset($_POST['submit'])){
74                             $target_dir =
"../photo/";
75                             $target_file = $target_dir . basename($_FILES[
"pic"]["name"]);
76                             $uploadOk =
1;
77                             $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
78                             
// Check if image file is a actual image or fake image
79
80                             $check = getimagesize($_FILES[
"pic"]["tmp_name"]);
81                             
if($check !== false) {
82                                 
// echo "File is an image - " . $check["mime"] . ".";
83                                 $uploadOk =
1;
84                             }
else {
85                                 echo
"File is not an image.";
86                                 $uploadOk =
0;
87                             }
88
89                             
// Check if file already exists
90                             
if (file_exists($target_file)) {
91                                 echo
"<script>alert('Sorry, file already exists.');</script>";
92                                 $uploadOk =
0;
93                             }
94                             
//aloow certain file formats
95                             
if($imageFileType != "jpg" && $imageFileType !="PNG" && $imageFileType !="jpeg" && $imageFileType !="gif"){
96                                 echo
"sorry, only jpg, jpeg, Png & gif files are allowed.";
97                                 $uploadok=
0;
98                             }
99                         
else{
100                             
if(move_uploaded_file($_FILES["pic"]["tmp_name"], $target_file)) {
101                                     include(
'../config.php');
102                                     $sql1 =
"SELECT * FROM doctor WHERE userid='".$_POST["userid"]."' OR email= '" . $_POST["email"] . "' ";
103                                     $result = $conn->query($sql1);
104                                     
if($result->num_rows > 0){
105                                          echo
"<script>alert('Sorry, Userid or E-mail already exist!');</script>";
106                                     }
107                                     
else{
108                                     $sql =
"INSERT INTO doctor (name,address,contact,email,expertise,userid,fee,password,pic)
109                                         VALUES ('"
. $_POST["name"] . "','" . $_POST["address"] . "','" . $_POST["contact"] . "','" . $_POST["email"] . "', '" . $_POST["expertise"] . "','" . $_POST["userid"] . "','" . $_POST["fee"] . "','" . $_POST["password"] . "','" . basename($_FILES["pic"]["name"]) ."' )";
110
111                                         
if ($conn->query($sql) === TRUE) {
112                                             echo
"<script>alert('New Doctor Has been Added Successfully!');</script>";
113                                         }
else {
114                                             echo
"<script>alert('There was an Error')<script>";
115                                         }
116                                     }
117
118                                     $conn->close();
119                             }
else {
120                                 echo
"<script>alert('sorry there was an error!');</script>";
121                             }
122                             
123                             
124                         }
125                 }
126                 ?>
127                     <!-- inserting data -->
128
129     
130
131
132
133     
134     </div><!-- containerFluid Ends -->
135
136
137
138
139     <script src=
"js/bootstrap.min.js"></script>
140
141
142     
143
144
145
146 </body>
147 </html>


Gõ tìm kiếm nhanh...